Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Get log for a project #153

Merged
merged 2 commits into from
Aug 19, 2014
Merged

Get log for a project #153

merged 2 commits into from
Aug 19, 2014

Conversation

marcelometal
Copy link
Member

Return git log for a given repository.

@marcelometal
Copy link
Member Author

Please review my patch! ;-)

func GetLog(w http.ResponseWriter, r *http.Request) {
repo := r.URL.Query().Get(":name")
ref := r.URL.Query().Get("ref")
total, _ := strconv.Atoi(r.URL.Query().Get("total"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you are ignoring this error. What will happens if total can't be converted to int?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total will be 0 and GetLog will return only one entry :-P

But yes, a bad request would be better.

@andrewsmedina
Copy link
Contributor

@marcelometal sorry for the delay. See the comments above.

b, err := json.Marshal(logs)
if err != nil {
err := fmt.Errorf("Error when trying to obtain log for ref %s of repository %s (%s).", ref, repo, err)
http.Error(w, err.Error(), http.StatusBadRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a json marshalling error be a bad request? I believe http.StatusInternalServerError fits better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I will send a patch to fix all others handlers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, thanks! :)

@marcelometal
Copy link
Member Author

Done! Please review again ;-)

@fsouza
Copy link
Contributor

fsouza commented Aug 19, 2014

LGTM

@andrewsmedina feel free to merge it when you're good :)

andrewsmedina added a commit that referenced this pull request Aug 19, 2014
@andrewsmedina andrewsmedina merged commit bd88ce1 into tsuru:master Aug 19, 2014
@andrewsmedina
Copy link
Contributor

@marcelometal thank you!

@marcelometal marcelometal deleted the getlog branch August 22, 2014 19:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants